﻿<!doctype html>
<html>
<!-- InstanceBegin template="/Templates/template1.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>获奖名单</title>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../js/common.js"></script>
<link href="../css/Pager.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../js/utils.js"></script>
<script type="text/javascript" src="../js/jquery.pager.js"></script>
<script type="text/javascript" src="../js/checkLogin.js"></script> 
<script type="text/javascript" src="../js/scrollTop.js"></script>
<link href="../css/style.css" type="text/css" rel="stylesheet" />
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<script type="text/javascript">
var pagecount = 0;
var pageIndex=1;
var count=0;

$(function(){
	findSweepstakesList()
})
function findSweepstakesList(){
	$.ajax({
		url:'../sweepstakes/find/sweepstakesList/'+pageIndex+'/10',
		datatype:'json',
		data:'status=2',
		type:'get',
		success:
			function(data){
			var rst= JSON.parse(data);
			if(IsEmpty(rst)){
				art.dialog({fixed:true, lock: true,content:"修改出錯",icon:'error',ok:true});	
				return false;
				}
				if(rst.state==0){
					if(rst.result.len>0){
						loadtable(rst)	
						 var shu = rst.result.len;
						 pagecount = Math.ceil(shu/10);
						 $("#pager").pager({ pagenumber:pageIndex, pagecount: pagecount, buttonClickCallback: PageClick });

						}
				}else if(rst.state==1){
					art.dialog({fixed:true, lock: true,content:rst.msg,icon:'error',ok:true});	
				}else{
					checkStateShowErrorMsgAndDealResult(data);
				}	
			
			
		}
	})
}

PageClick = function(pageclickednumber) {
	pageIndex=pageclickednumber;
	findSweepstakesList();
}
function loadtable(rst){
	var params = new Array("swptaksName", "swptaksContent","swptaksBeginDate","staName","status","swptaksID","prizeTypeId");// "PayCash", "PayPos", "PayDepstAmt", "PayCheck", "PayPersonCard", "PayIntAmtMny", "StaName", "PaidName"
	var phArray = new Array();
	var count=0;
	if (params != null) {
		$(params).each(function(pIndex, pData) {
			$.each(rst.result.head, function(hIndex, hData) {
				if (pData == hData) {
					phArray[count++] = hIndex;
				}
			});
		});
	}
	
			$("#rewardList").empty();
		for ( var i = 0; i < rst.result.data.length; i++) {
			 var htm="<li>";
			var d=rst.result.data[i]
	
			for ( var j = 0; j < phArray.length; j++) {
				if(j==0){
					htm+="<strong>"+d[phArray[j]]+"</strong>"
				}else
				if(j==1){
					htm+="<p>"+d[phArray[j]]+"</p>";
				}else if(j==2){
					
				htm+= "<b>"+ d[phArray[j]] +"</b>"
				}else if(j==3){
				htm+= "<span>"+ d[phArray[j]] +"</span>"
				}else if(j==4){
					if(d[phArray[j]]==0||d[phArray[j]]==1){
						htm+="<i><input class=\"common_btn newAward\" type=\"button\" value=\"开奖\" onclick=\"openAward("+d[phArray[5]]+","+d[phArray[6]]+",$(this) )\" ></i>"	
					}else if(d[phArray[j]]==2){
						htm+="<i><input class=\"common_btn\" type=\"button\" value=\"查询获奖名单\" onclick=\"InitTable("+d[phArray[5]]+")\"></i>"
					}
				}
			}
			htm+="</li>";
			$("#rewardList").append(htm)
		}

}

function InitTable(id) {
	
	
	$.ajax({
		type : "get",
		async:false,
		data:'swptaksId='+id,
		datatype : "json",
		url : "../winner/find/winnerList",
		success : function(data) {
			var rst = JSON.parse(data);
					if(IsEmpty(rst)){
						art.dialog({fixed:true, lock: true,content:"修改出錯",icon:'error',ok:true});	
						return false;
						}
						if(rst.state==0){
							if(rst.result.len > 0){
								$("#partNum1").html("参加人数："+getHeadIndexValue(0, rst, "particNums"))
								loadawardtable(rst);
						}
						}else if(rst.state==1){
							art.dialog({fixed:false, lock: true,content:rst.msg,icon:'error',ok:true});	
						}else{
							checkStateShowErrorMsgAndDealResult(data);
						}		
		}	
	});
	
		
	
}

function	loadawardtable(rst){
	var params = new Array("CusName", "Mp","Pname","CreateTime");// "PayCash", "PayPos", "PayDepstAmt", "PayCheck", "PayPersonCard", "PayIntAmtMny", "StaName", "PaidName"
	var phArray = new Array();
	var count=0;
	if (params != null) {
		$(params).each(function(pIndex, pData) {
			$.each(rst.result.head, function(hIndex, hData) {
				if (pData == hData) {
					phArray[count++] = hIndex;
				}
			});
		});
	}
	
			$("#div1 ul").empty();
		for ( var i = 0; i < rst.result.data.length; i++) {
			 var htm="<li>";
			var d=rst.result.data[i]
	
			for ( var j = 0; j < phArray.length; j++) {
				if(j==1){
					htm+="<i>电话：</i>";
					htm+=getReplaceStr(d[phArray[j]],3,7,"****");

				}else{
					
			htm+= d[phArray[j]]
				}
			}
			htm+="</li>";
			$("#div1 ul").append(htm)
		}
		$("#yinying1,#windowPop").show();
		ScrollTop("div1");
}



</script>

</head>

<body>
<!-- InstanceBeginEditable name="EditRegion3" -->
<script type="text/javascript">
$(function(){
	Hover($("#rewardList"));
	$("#closeThe,#esc,#safe").click(function(){
		$("#windowPop,#yinying1").hide();
	})
	$("#rewardList i").children(":button").click(function(){
		$("#yinying1,#windowPop").show();
		//ScrollTop("div1");
	})
	addMargin($("#windowPop"));
})
</script>
<div id="windowPop" class="hideDiv">
  <div class="closeTop"><span id="closeThe"><img src="../images/close.png"></span></div>
  <div class="boxcontent box_blue">
    <div class="box_activities">
      <div class="title"><span>中奖公告：</span><i id="partNum1"></i></div>
      <div class="Detail" id="div1">
        <ul class="rewardPeople">
         </ul>
       
      </div>
    </div>
  </div>
</div>
<div id="yinying1"></div>
<div class="container" id="container">
  <div class="container_R fr">
    <div class="place">获奖名单</div>
    <div class="rewardTitle"><b class="name">活动名称</b><b class="det">活动简介</b><b class="date">开奖日期</b><b class="state">状态</b><b class="set">操作</b></div>
    <ul class="rewardList" id="rewardList">
      
    </ul>
    <div id="pager"></div>
  </div>
  <div class="fc"></div>
</div>
<!-- InstanceEndEditable --> 
<script type="text/javascript" src="../js/header.js"></script> 
<script type="text/javascript" src="../js/left.js"></script> 
<script type="text/javascript" src="../js/footer.js"></script> 
<script type="text/javascript">
showTab(3,3);
</script>
</body>
<!-- InstanceEnd -->
</html>
